<?php

// +----------------------------------------------------------------------
// | 版权所有 2017-2027 云南环拓科技有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2027 http://www.yn123.com All rights reserved.
// +----------------------------------------------------------------------
// | Notice: This code is not open source, it is strictly prohibited
// |         to distribute the copy, otherwise it will pursue its
// |         legal responsibility.
// | 注意：  这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用,
// |        不允许对程序代码以任何形式任何目的的再发布。
// +----------------------------------------------------------------------
// | Author: feraner <feraner@163.com> 
// | Date: 2019/11/17
// +----------------------------------------------------------------------

namespace app\common\tools;
use Carbon\Carbon;

/**
 * 判断兼职是否可以操作类
 * Class JobOptions
 * @package app\common\tools
 * @author feraner<feraner@163.com>
 * @date 2019/11/17
 */
class JobOptions
{


    /**
     * 判断兼职是否可以关闭招聘报名
     * @param array $jobInfo
     *
     * @return bool
     */
    public function isCloseApply($jobInfo = [])
    {
        if (\app\common\facade\Arr::valueEq($jobInfo, 'status', 2) &&
            !\app\common\facade\Arr::get($jobInfo, 'is_deleted')) {
            return true;
        }
        return false;
    }


    /**
     * 判断兼职是否可以置顶
     * @param array $jobInfo
     *
     * @return bool
     */
    public function isTop($jobInfo = [])
    {
        if ($this->isCloseApply($jobInfo) && \app\common\facade\Arr::get($jobInfo, 'is_top') == 0) {
            return true;
        }
        return false;
    }



    /**
     * 判断兼职是否可以结束结算
     * @param array $jobInfo
     *
     * @return bool
     */
    public function isJobDone($jobInfo = [])
    {
        $workTime = \app\common\facade\Arr::get($jobInfo, 'work_time');
        $todayTime = Carbon::today()->addHour(23)->addMinutes(59)->getTimestamp();
        if (\app\common\facade\Arr::valueEq($jobInfo, 'status', 4) &&
        $todayTime >= $workTime && !\app\common\facade\Arr::get($jobInfo, 'is_deleted')) {
            return true;
        }
        return false;
    }


}
